package transport

import (
	"context"
	pb "go-kit-service/api/video"
	"go-kit-service/pkg/endpoint"

	grpcKit "github.com/go-kit/kit/transport/grpc"
)

const (
	// 最大传输文件大小为 1M
	ChunckSize = 1 << 20
)

type grpcServer struct {
	videoList     grpcKit.Handler
	uploadVideo   grpcKit.Handler
	downloadVideo grpcKit.Handler
	convertVideo  grpcKit.Handler
	pb.UnimplementedVideoServer
}

func NewGRPCServer(endpoint endpoint.Endpoints) *grpcServer {
	return &grpcServer{
		videoList: grpcKit.NewServer(
			endpoint.VideoListEndpoint,
			decGRPCVideoListRequest,
			encGRPCVideoListResponse,
		),
		uploadVideo: grpcKit.NewServer(
			endpoint.UploadVideoEndpoint,
			decGRPCUploadVideoRequest,
			encGRPCUploadVideoResponse,
		),
		downloadVideo: grpcKit.NewServer(
			endpoint.DownloadVideoEndpoint,
			decGRPCDownloadVideoRequest,
			encGRPCDownloadVideoResponse,
		),
		convertVideo: grpcKit.NewServer(
			endpoint.ConvertVideoEndpoint,
			decGRPCConvertVideoRequest,
			encGRPCConvertVideoResponse,
		),
	}
}

func decGRPCVideoListRequest(ctx context.Context, req interface{}) (interface{}, error) {

	return nil, nil
}

func encGRPCVideoListResponse(ctx context.Context, resp interface{}) (interface{}, error) {

	return resp, nil
}

func decGRPCUploadVideoRequest(ctx context.Context, req interface{}) (interface{}, error) {

	return req, nil
}

func encGRPCUploadVideoResponse(ctx context.Context, resp interface{}) (interface{}, error) {

	return resp, nil
}

func decGRPCDownloadVideoRequest(ctx context.Context, req interface{}) (interface{}, error) {

	return req, nil
}

func encGRPCDownloadVideoResponse(ctx context.Context, resp interface{}) (interface{}, error) {

	return resp, nil
}

func decGRPCConvertVideoRequest(ctx context.Context, req interface{}) (interface{}, error) {

	return req, nil
}

func encGRPCConvertVideoResponse(ctx context.Context, resp interface{}) (interface{}, error) {

	return resp, nil
}
